package com.ymatou.iapi.godmch.service;

import java.util.ArrayList;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ymatou.iapi.godmch.parameter.CountryInfo;
import com.ymatou.iapi.godmch.parameter.CsBaseVo;
import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;
/**
*获取国家列表Call
*FreeMaker Template自动生成代码
*/
public class listcountryCall extends YmatouBaseCall{
	private static String opurl ="api/country/list";
	
	public listcountryCall() {
		super(EnvSetup.getSystemUrl("godmch_iapi"),opurl,"GET","PARAM");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	public ArrayList<CountryInfo> getCountryInfos() {
		ArrayList<CountryInfo> result =null;
		try {
			result = (ArrayList<CountryInfo>) new Gson().fromJson(getJsonObject().get("result").getAsJsonObject().get("countries").getAsJsonArray().toString(), new TypeToken<ArrayList<CountryInfo>>() {}.getType());
		} catch (Exception e) {
//			e.printStackTrace();
		}
		return result;
	}
}